home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-25 | 5.0 KB | 108 lines | [TEXT/MACA] |
- ; (c) Copyright 1990 by University of Massachusetts. All rights reserved.
- ; This software was conceived, designed, and written by Dan Suthers
- ; while supported by the National Science Foundation under grant number
- ; MDR 8751362, and by a fellowship from Apple Computer, Inc., Cupertino,
- ; CA. Partial support was also received from the Office of Naval Research
- ; under a University Research Initiative Grant, contract N00014-86-K-0764.
- ; Mr. Suthers created this software under his own initiative while in an
- ; academic relationship with the University of Massachusetts. The above
- ; copyright notice was a condition placed by University lawyers on approval
- ; of distribution of this software by Apple Computer, and is not meant to
- ; imply that this software was created in an employment or "work for hire"
- ; relationship between the University and Mr. Suthers.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; File: CONTROL.lisp
- ; Author: Dan Suthers
- ; Created: 16-Jun-88 10:37:12
- ; Modified: 22-Jun-90 02:08:13 (Dan Suthers)
- ; Language: Common Lisp
- ; Package: UTILS
- ;
- ; Description: Additional control constructs.
- ;
- ; (c) Copyright 1988, by Daniel D. Suthers
- ; Department of Computer and Information Science
- ; University of Massachusetts
- ; Amherst, Massachusetts 01003
- ;
- ; This software was conceived, designed, and written by Dan Suthers
- ; while supported by the National Science Foundation under grant number
- ; MDR 8751362, and by a fellowship from Apple Computer, Inc., Cupertino,
- ; CA. Partial support was also received from the Office of Naval Research
- ; under a University Research Initiative Grant, contract N00014-86-K-0764.
- ; I wish to acknowledge the generous support of Beverly Woolf, who obtained
- ; the above grants and encouraged me to pursue my own research interests in
- ; her lab. This work would not have been possible without the resources and
- ; stimulating environment of the Computer and Information Science department.
- ;
- ; Permission to use, modify, and distribute this software is granted subject
- ; to the following restrictions and understandings:
- ; 1. The file header, including this notice, shall be retained, and may be
- ; extended to include documentation of modifications to the software.
- ; 2. This material is for nonprofit educational and research purposes only.
- ; Users are requested, but not required, to inform Mr. Suthers of any
- ; noteworthy uses of this software.
- ; 3. Mr. Suthers and the University of Massachusetts make no warrantee or
- ; representation that the operation of this software will be error free,
- ; and are under no obligation to provide any services.
- ; 4. Any user of such software agrees to indemnify and hold harmless Mr.
- ; Suthers and the University of Massachusetts from all claims arising
- ; out of the use or misuse of this software, or arising out of any
- ; accident, injury, or damage whatsoever, and from all costs, counsel
- ; fees, and liabilities incurred in or about any such claim, action, or
- ; proceeding brought thereon.
- ; 5. All materials and reports developed as a consequence of the use of
- ; this software shall duly acknowledge such use, in accordance with
- ; the usual standards of acknowledging credit in academic research.
- ;
- ; Status: Done and tested.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (in-package :UTILS)
-
- (export '(
- insist
- pause
- random-choice
- ))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- ;;; This needs rewrite to use gensym.
-
- (defmacro INSIST (&rest body)
- "insist <form> ... [Macro]
- Evaluates a body of forms until the last one returns a non-nil value."
- `(do (($$result$$ nil))
- ($$result$$ $$result$$)
- (setf $$result$$
- (progn ,@body))))
-
- (defun PAUSE (&optional (stream T) escape-char)
- "pause &optional <stream> <escape-char> [Function]
- Pauses output to stream, asking the user to type Return to continue.
- Stream defaults to T. If <escape-char> is specified, PAUSE will also
- tell the user to type <escape-char> to quit, and THROW <escape-char>
- to :escape-pause if it is read. NOTE: <escape-char> must be a character!"
- (if escape-char
- (progn
- (format stream "~%(Return to continue, ~S to quit):" escape-char)
- (if (equal (read-char stream) escape-char)
- (throw :escape-pause escape-char)))
- (progn
- (format stream "~%(Return to continue):")
- (read-char stream) )))
-
- (defmacro RANDOM-CHOICE (options)
- "random-choice <options> [Macro]
- Randomly chooses one of the elements of the list <options> evaluates to."
- `(let ((options ,options))
- (if options
- (nth (random (length options)) options))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (provide :CONTROL)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; EOF
-